<%--
  Created by IntelliJ IDEA.
  User: lcc
  Date: 2021/12/4
  Time: 11:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/common.jsp"%>
<html>
<head>
    <title>Title</title>
    <script>
        function deng(){
            $.ajax({
                url:"<%=path%>/player/getInfod",
                type:"post",
                dateType:"json",
                data:$("#login").serialize(),
                async:true,
                success:function (result){
                    if (result == 1){
                        toastr.error("偷渡者禁入")
                    }else if (result == 2){
                        toastr.error("玩家已冻结,请联系系统管理员解冻")
                    }else if (result == 3){
                        toastr.warning("玩家账号或密码错误")
                    }else if (result == 4){
                        toastr.info("登陆成功")
                        location.href = "<%=path%>/menu/show"
                    }else if (result == 5){
                        toastr.warning("验证码错误")
                    }
                },
                error:function (result){
                    console.log(result)
                }
            })
        }

        //增加
        function log(){
            //点击增加按钮,弹出窗口,跳转增加页面
            BootstrapDialog.show({
                title: '很抱歉，目前尚未开通注册功能，请联系系统创造者/管理员/唯一员工--秦无解--qq--3470669812，由他手动注册',
                <%--message: $('<div></div>').load("<%=path%>/user/toAdd"),--%>
                <%--//弹出框的大小--%>
                <%--size: BootstrapDialog.SIZE_WIDE,--%>
                <%--buttons: [{--%>
                <%--    label: '取消',--%>
                <%--    action: function (dialog) {--%>
                <%--        dialog.close();--%>
                <%--    }--%>
                <%--}, {--%>
                <%--    label: '确定',--%>
                <%--    action: function (dialog) {--%>
                <%--        $.ajax({--%>
                <%--            url : "<%=path%>/user/addInfo",--%>
                <%--            type : "post",--%>
                <%--            dataType : "json",--%>
                <%--            data : $("#user_add_form").serialize(),--%>
                <%--            success : function (result){--%>
                <%--                if (result){--%>
                <%--                    toastr.success("增加成功");--%>
                <%--                    dialog.close();--%>
                <%--                    getData();--%>
                <%--                }--%>

                <%--            },--%>
                <%--            error : function (result){--%>
                <%--                toastr.error("增加失败");--%>
                <%--                console.log(result);--%>
                <%--            }--%>
                <%--        })--%>
                <%--    }--%>
                <%--}]--%>
            });
        }

        function selectUser(){
            $.ajax({
                url : "<%=path%>/player/selectUser",
                type : "post",
                data : $("#login").serialize(),
                dataType : "json",
                success : function (result){
                    if (result == 1) {
                        $("#showSpan").html("<font color='red'>尊贵的内测玩家，欢迎登录您的专属系统</font>");
                        $("#zhu").attr("onclick","")
                    }else {
                        $("#showSpan").html("<font color='green'>滴·检测到身份不明者，已驳回本次登录诉求</font>");
                        $("#zhu").attr("onclick","log()")
                    }
                },
                error : function(result){
                    console.log(result);
                }
            })
        }


        function change_img(){
            $("#img_id").attr("src","<%=path%>/code/vcode?time" + new Date().getTime());

        }

        //自动输入验证码
        $.get("<%=path%>/code/getCode",function (result){
            $("[name=vcode]").val(result);
        })
    </script>
</head>
<body>
    <center>
        <form id="login" >
            <div class="container-fluid">
                <div class="panel panel-primary" style="width:400px">
                    <div class="panel-heading">
                        <h1>登录</h1>
                    </div>
                    <div class="panel-body">
                        <form id="loginForm">
                            <div class="form-group">
                                <input type="text" class="form-control" name="playerAccount" id="playerAccount"
                                       placeholder="请输入账号" onblur="selectUser()"><span id="showSpan"></span>
                                <div id="tips"></div>
                            </div>
                            <div class="form-group">
                                <input type="password" placeholder="请输入密码" class="form-control" name="playerPw" id="playerPw">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" name="vcode" id="vcode"
                                       placeholder="请输入验证码">
                                <img src="<%=path%>/code/vcode" id="img_id" width="80px" height="40px" onclick="change_img()"><br>
                            </div>
                            <input type="button" class="btn btn-success btn-lg" value="登录" onclick="deng()">
                            <input type="button" class="btn btn-success btn-lg" value="注册" onclick="log()" id="zhu">
                        </form>
                    </div>
                    <div class="panel-footer">
                        <a href="/">验证码不想输入？点击本行可自动填写 ๑乛◡乛๑</a>
                    </div>
                </div>
            </div>
        </form>
    </center>
</body>
</html>
